Skip to content

fix: memory leak in serde - #597

Open
proost wants to merge 2 commits into
apache:masterfrom
proost:fix-memory-leak
Open

proost wants to merge 2 commits into
apache:masterfrom
proost:fix-memory-leak

Conversation

@proost

@proost proost commented Nov 22, 2026

Copy link
Copy Markdown
Member

when bad_alloc happens, we do not free strings in the array.

@proost proost self-assigned this Nov 22, 2026
@proost
proost requested a review from leerho November 22, 2026 08:27

@leerho leerho left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is right: a bad_alloc or length_error from reserve() or push_back() left items[0..i) constructed. The bytes overload has the same gap: new (&items[i]) std::string(static_cast<const char*>(ptr), length) can throw bad_alloc after earlier items were constructed, and only the failure path cleans them up. Could you handle that one the same way here, so both overloads match?

@proost
proost requested a review from leerho November 23, 2026 09:05
@proost

proost commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

@leerho
You are right, i missed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants